using I2.Loc;
using UnityEngine;

public class MarketCarInfoPanel : MarketProductInfoPanel
{
	public UILabel accelerationCount;

	public UILabel controlCount;

	public UILabel speedCount;

	public UILabel strengthCount;

	public UILabel accelerationCountTank;

	public UILabel controlCountTank;

	public UILabel speedCountTank;

	public UILabel strengthCountTank;

	public GameObject carData;

	public GameObject tankData;

	public UILabel damageCount;

	public UILabel ammoCount;

	public GameObject titanData;

	public UILabel mainDamageCount;

	public UILabel secondDamageCount;

	public UISprite carTypeSprite;

	public UILabel carTypeLabel;

	public UISprite rareTypeSprite;

	public UILabel rareTypeLabel;

	public GameObject accelerationData;

	public GameObject controlData;

	public override void SetInfo(Product product, bool setUpgrades, bool needComparison = true)
	{
		currentProduct = product;
		base.SetInfo(product, setUpgrades);
		float carUpgradeCoef = MarketController.Instance.GetCarUpgradeCoef(product.id, UpgradeType.Body);
		float carUpgradeCoef2 = MarketController.Instance.GetCarUpgradeCoef(product.id, UpgradeType.Engine);
		float carUpgradeCoef3 = MarketController.Instance.GetCarUpgradeCoef(product.id, UpgradeType.Intake);
		float carUpgradeCoef4 = MarketController.Instance.GetCarUpgradeCoef(product.id, UpgradeType.Wheels);
		ProductCar productCar = ((!needComparison) ? product : MarketControllerUI.instance.selectedProduct) as ProductCar;
		if ((bool)accelerationData)
		{
			accelerationData.SetActive(false);
		}
		if ((bool)controlData)
		{
			controlData.SetActive(true);
		}
		controlCount.text = (productCar.control * carUpgradeCoef4).ToString("F0");
		speedCount.text = (productCar.speed * carUpgradeCoef2).ToString("F0");
		strengthCount.text = (productCar.strength * carUpgradeCoef).ToString("F0");
		carTypeSprite.spriteName = "CarProductType_" + productCar.carType;
		carTypeLabel.text = ScriptLocalization.Get("Market/CarType_" + productCar.carType);
		rareTypeSprite.spriteName = "RareType_" + productCar.rare;
		rareTypeLabel.text = ScriptLocalization.Get("Market/RareType_" + productCar.rare);
		carTypeSprite.gameObject.SetActive(true);
		if ((bool)carData)
		{
			carData.SetActive(true);
		}
		if (productCar is ProductTank)
		{
			ProductTank productTank = (ProductTank)productCar;
			tankData.SetActive(true);
			if ((bool)titanData)
			{
				titanData.SetActive(false);
			}
			damageCount.text = (productTank.damage * carUpgradeCoef3).ToString("F0");
			ammoCount.text = productTank.ammo.ToString("F0");
			if ((bool)carData)
			{
				carData.SetActive(false);
				if ((bool)accelerationCountTank)
				{
					accelerationCountTank.text = (productCar.acceleration * carUpgradeCoef3).ToString("F0");
				}
				if ((bool)controlCountTank)
				{
					controlCountTank.text = (productCar.control * carUpgradeCoef4).ToString("F0");
				}
				if ((bool)speedCountTank)
				{
					speedCountTank.text = (productCar.speed * carUpgradeCoef2).ToString("F0");
				}
				if ((bool)strengthCountTank)
				{
					strengthCountTank.text = (productCar.strength * carUpgradeCoef).ToString("F0");
				}
			}
		}
		else if (productCar is ProductTitan)
		{
			ProductTitan productTitan = (ProductTitan)productCar;
			tankData.SetActive(false);
			carTypeSprite.gameObject.SetActive(false);
			if ((bool)titanData)
			{
				titanData.SetActive(true);
			}
			if ((bool)mainDamageCount)
			{
				mainDamageCount.text = (productTitan.mainWeaponDamage * carUpgradeCoef3).ToString("F0");
			}
			if ((bool)secondDamageCount)
			{
				secondDamageCount.text = (productTitan.additionalWeaponDamage * carUpgradeCoef4).ToString("F0");
			}
			if ((bool)accelerationData)
			{
				accelerationData.SetActive(false);
			}
			if ((bool)controlData)
			{
				controlData.SetActive(false);
			}
			if ((bool)carData)
			{
				carData.SetActive(false);
				if ((bool)accelerationCountTank)
				{
					accelerationCountTank.text = (productCar.acceleration * carUpgradeCoef3).ToString("F0");
				}
				if ((bool)controlCountTank)
				{
					controlCountTank.text = (productCar.control * carUpgradeCoef4).ToString("F0");
				}
				if ((bool)speedCountTank)
				{
					speedCountTank.text = (productTitan.speed * carUpgradeCoef2).ToString("F0");
				}
				if ((bool)strengthCountTank)
				{
					strengthCountTank.text = (productTitan.strength * carUpgradeCoef).ToString("F0");
				}
			}
		}
		else
		{
			if ((bool)titanData)
			{
				titanData.SetActive(false);
			}
			tankData.SetActive(false);
		}
		SetTitleLocalization();
		SetDescriptionLocalization();
	}
}
